package com.naiterui.ehp.bs.b2c.product.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.b2c.product.exception.ProductExceptionCodes;
import com.naiterui.ehp.bs.b2c.product.service.ICategoryService;
import com.naiterui.ehp.bs.b2c.product.vo.CategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <pre>
 * 商品分类相关
 * </pre>
 *
 * @author fangguanhong
 * @date 2019/5/22 下午3:01
 * @since 1.0.0
 */
@Api(tags = SwaggerTag.DOCTOR + SwaggerTag.MEDICINE_DRUG)
@RequestMapping("b2c/category")
@RestController
public class CategoryController {

    private static final Logger LOGGER = LoggerFactory.getLogger(CategoryController.class);

    @Autowired
    private ICategoryService categoryService;

    /**
     * 获取商品分类数据
     *
     * @return
     */
    @ApiOperation(value = "商品分类信息")
    @PostMapping("/list")
    public ResponseVO<List<CategoryVO>> categorys() {
        LOGGER.info("获取分类数据!");
        List<CategoryVO> result = categoryService.getCategoryList();
        return PublicService.returnResponseVO(ProductExceptionCodes.SUCCESS, result);
    }
}
